var Cookie = function(opt)
{
    this.time = 1000 * 60 * 60; // 默认1小时
    this.domain = '.bitcarnie.com';
    this.path = '/';

    // 设置cookie值
    this.set = function (name, value)
    {
        var
        oDate = new Date(),
        value = {
            data: value
        };
        oDate.setTime(oDate.getTime() + this.time);
        document.cookie = name + '=' + JSON.stringify(value) + ';domain=' + this.domain + ';path=' + this.path + ';expires=' + oDate.toGMTString() + ';';
    };

    // 获取cookie值
    this.get = function (name)
    {
        var name = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++)
        {
            var c = ca[i].trim();
            if (c.indexOf(name)==0) return JSON.parse(c.substring(name.length,c.length)).data;
        }
        return null;
    }

    // 删除cookie值
    this.del = function(name)
    {
        this.time = -1;
        this.set(name, null);
    }

    // 删除所有cookie值
    this.delAll = function()
    {
        var all = document.cookie.split(';');
        for(var i=0; i<all.length; i++)
        {
            var dname = ca[i].trim().split('=')[0];
            // 删除
            this.del(dname);
        }
    }

    // 设置参数
    this.setOpt = function(opt)
    {
        console.log(opt)
    }

    // 初始设置参数
    this.setOpt(opt);
};